package com.ssy.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssy.common.Constant;
import com.ssy.common.utils.Result;
import com.ssy.system.mapper.CommonTypeMapper;
import com.ssy.system.pojo.CommonType;
import com.ssy.system.service.ICommonTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author ssy
 */
@Service
public class CommonTypeServiceImpl extends ServiceImpl<CommonTypeMapper, CommonType> implements ICommonTypeService {

    @Autowired
    private CommonTypeMapper commonTypeMapper;

    @Override
    public Result queryAllCommonType(String type) {
        List<CommonType> commonTypes = this.commonTypeMapper.selectList(new LambdaQueryWrapper<CommonType>()
                .eq(CommonType::getTypeCode, type)
                .notIn(CommonType::getId, Constant.USER_TYPE_SUPER));
        return new Result(commonTypes);
    }

    @Override
    public CommonType queryCommonTypeById(Integer id) {
        return this.commonTypeMapper.selectById(id);
    }
}
